/*
* @author : TF-BJ-C064
* @creation : 2014-6-26 下午4:43:33
* @description : 
*
*/

package com.service.impl;

import java.sql.Timestamp;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;

import org.apache.log4j.Logger;

import com.action.park.MyPayStatisticsAction;
import com.bean.ParkAccountRecord;
import com.bean.PayMent;
import com.bean.TfAccountRecord;
import com.dao.PayStatisticsDao;
import com.service.PayStatisticsService;
import com.tool.RegexTool;
import com.util.GUtil;

/**
 * 收支统计
 * <p>Title: PayStatistics</p>
 * <p>Description: </p>
 * <p>Company: www.teleframe.cn</p> 
 * @author	lijian
 * @date	2014-6-26
 */
public class PayStatisticsServiceImpl implements PayStatisticsService {
	
	private Logger log = Logger.getLogger(PayStatisticsServiceImpl.class);
	private static String Tag = PayStatisticsServiceImpl.class.getName();

	PayStatisticsDao dao;
	
	@Override
	public Object get(Integer id) throws Exception {
		return null;
	}

	@Override
	public List<Object> query(Object object) throws Exception {
		return null;
	}

	@Override
	public String update(Object object) throws Exception {
		return null;
	}

	@Override
	public String delete(Integer id, Integer flag) throws Exception {
		return null;
	}

	@Override
	public List findByProperty(String propertyName, Object value)
			throws Exception {
		return null;
	}

	@Override
	public List findByExample(Object object) throws Exception {
		return null;
	}

	/**
	 * 按天收支统计
	 * <p>Title: queryByDay</p>
	 * <p>Description: </p>
	 * @param payInOut 收入和支出列表
	 * @param payStat  根据category类型统计的列表
	 * @param daytime  日期，精确到天,e.g: 2014-5-06
	 * @return
	 * @throws Exception
	 * @see com.service.PayStatisticsService#queryByDay(com.bean.PayMent, com.bean.PayMent, java.sql.Timestamp)
	 */
	@Override
	public String queryByDay(List<ParkAccountRecord> payInOut, List<ParkAccountRecord> payStat, String daytime, Long userId)
			throws Exception {
		
		if(RegexTool.checkDateTime(daytime)){
			return dao.queryByDay(payInOut, payStat, daytime, userId);
		}else{
			return "日期错误";
		}
	}
	/**
	 * 按周收支统计
	 * <p>Title: queryByWeek</p>
	 * <p>Description: </p>
	 * @param payInOut 收入和支出列表
	 * @param payStat  根据category类型统计的列表
	 * @param daytime  日期，精确到天,e.g: 2014-5-06
	 * @param paylistInOutByDay   
	 * @return
	 * @throws Exception
	 * @see com.service.PayStatisticsService#queryByDay(com.bean.PayMent, com.bean.PayMent, java.sql.Timestamp)
	 */
	@Override
	public Double[][] queryByWeek(List<ParkAccountRecord> payInOut,
			List<ParkAccountRecord> payStat,
			Map<Double, Double> paylistInOutByDay, String daytime, Long userId)
			throws Exception {
		if(RegexTool.checkDateTime(daytime)){
			return dao.queryByWeek(payInOut, payStat, paylistInOutByDay, daytime, userId);
		}else{
			log.error(this.getClass()+".queryByYear() 日期错误");
			return null;// "日期错误";
		}
	}
	/**
	 * 按月收支统计
	 * <p>Title: queryByMonth</p>
	 * <p>Description: </p>
	 * @param payInOut  收入和支出列表
	 * @param payStat   根据category类型统计的列表
	 * @param paylistInOutByDay  按天排列的收入和支持列表
	 * @param daytime  日期，精确到月, e.g: 2014-05
	 * @param userId
	 * @return
	 * @throws Exception
	 * @see com.service.PayStatisticsService#queryByMonth(java.util.List, java.util.List, java.util.List, java.lang.String, java.lang.Long)
	 */
	@Override
	public Double[][] queryByMonth(List<ParkAccountRecord> payInOut,
			List<ParkAccountRecord> payStat,
			Map<Double, Double> paylistInOutByDay, String daytime, Long userId)
			throws Exception {
		
		if(RegexTool.checkMonth(daytime)){
			return dao.queryByMonth(payInOut, payStat, paylistInOutByDay, daytime, userId);
		}else{
			log.error(this.getClass()+".queryByYear() 日期错误");
			return null;// "日期错误";
		}
	}
	/**
	 * 按月收支统计
	 * <p>Title: queryByYear</p>
	 * <p>Description: </p>
	 * @param payInOut
	 * @param payStat
	 * @param paylistInOutByMonth
	 * @param daytime
	 * @param userId
	 * @return
	 * @throws Exception
	 * @see com.service.PayStatisticsService#queryByYear(java.util.List, java.util.List, java.util.List, java.lang.String, java.lang.Long)
	 */
	@Override
	public Double[][] queryByYear(List<ParkAccountRecord> payInOut,
			List<ParkAccountRecord> payStat,
			Map<Double, Double> paylistInOutByMonth, String daytime, Long userId)
			throws Exception {
		
		if(RegexTool.checkYear(daytime)){
			return dao.queryByYear(payInOut, payStat, paylistInOutByMonth, daytime, userId);
		}else{
			log.error(this.getClass()+".queryByYear() 日期错误");
			return null;// "日期错误";
		}
	}

	public PayStatisticsDao getDao() {
		return dao;
	}
 
	public void setDao(PayStatisticsDao dao) {
		this.dao = dao;
	}



}
